<?php
/*
 * @author eBIZ Team <dev@jungo.com.cn>
 * @copyright  Copyright (c) , ShenZhen JunGO Technology Co., Ltd. All rights reserved.
 * @license  Commercial authorization, unauthorized use and modification are prohibited
 * @url www.jungo.com.cn
 */

namespace ckeeper\entity;


use ckeeper\services\RoleService;

class RoleEntity
{

    public int $id;

    public string $name;

    public string $rights = ':null';

    public string $description = ':null';

    public string $create_time;

    public string $status = 'enable';

    public function __construct()
    {
        $this->create_time = time();
    }

    /**
     * @return int
     */
    public function getId(): int
    {
        return $this->id;
    }

    /**
     * @param int $id
     * @return RoleEntity
     */
    public function setId(int $id): RoleEntity
    {
        $this->id = $id;
        return $this;
    }

    /**
     * @return string
     */
    public function getName(): string
    {
        return $this->name;
    }

    /**
     * @param string $name
     * @return RoleEntity
     */
    public function setName(string $name): RoleEntity
    {
        $this->name = $name;
        return $this;
    }

    /**
     * @return string
     */
    public function getRights(): string
    {
        if ($this->rights === ':null') {
            return '';
        }
        return $this->rights;
    }

    /**
     * @param string $rights
     * @return RoleEntity
     */
    public function setRights(string $rights): RoleEntity
    {
        $this->rights = $rights;
        return $this;
    }

    /**
     * @return string
     */
    public function getCreateTime(): string
    {
        return $this->create_time;
    }

    /**
     * @param string $create_time
     * @return RoleEntity
     */
    public function setCreateTime(string $create_time): RoleEntity
    {
        $this->create_time = $create_time;
        return $this;
    }

    /**
     * @return string
     */
    public function getStatus(): string
    {
        return $this->status;
    }

    /**
     * @param string $status
     * @return RoleEntity
     */
    public function setStatus(string $status): RoleEntity
    {
        if( empty($status) || $status === RoleService::STATUS_DISABLE ){
            $this->status = RoleService::STATUS_DISABLE;
        }else{
            $this->status = RoleService::STATUS_ENABLE;
        }
        return $this;
    }


    /**
     * @return string
     */
    public function getDescription():string
    {
        if ($this->description === ':null') {
            return '';
        }
        return $this->description;
    }

    /**
     * @param string $description
     * @return RoleEntity
     */
    public function setDescription(string $description): RoleEntity
    {
        $this->description = $description;
        return $this;
    }

}
